import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';


import '../../main.dart';

/*
class AudioRecorderPage extends StatefulWidget {
  @override
  _AudioRecorderPageState createState() => _AudioRecorderPageState();
}

class _AudioRecorderPageState extends State<AudioRecorderPage> {
  AudioRecorderService audioRecorderService = AudioRecorderService();

  @override
  void initState()  async {
    super.initState();

    // Initialize audio service for lock screen
    await JustAudioBackground.init(
      androidNotificationChannelId: 'com.ryanheise.bg_demo.channel.audio',
      androidNotificationChannelName: 'Audio playback',
      androidNotificationOngoing: true,
      androidShowNotificationBadge: true,
      preloadArtwork: true,
    );

    await initializeService();
    await initializeNotifications();

    audioRecorderService.initializeNotifications();
  }

  void initContextParams() async {


  }



  Future<void> initializeNotifications() async {


    if (await Permission.notification.isDenied) {
      await Permission.notification.request();
    }
    FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin;
    flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin();

    const AndroidInitializationSettings initializationSettingsAndroid =
    AndroidInitializationSettings('ic_launcher');



    const InitializationSettings initializationSettings = InitializationSettings(
      android: initializationSettingsAndroid,
    );

    await flutterLocalNotificationsPlugin?.initialize(
      initializationSettings,
      onDidReceiveNotificationResponse: (NotificationResponse response) async {
        if (response.payload != null) {
          debugPrint("Notification clicked with payload: ${response.payload}");
        }
      },
    );
  }



  Future<void> initializeService() async {
    final service = FlutterBackgroundService();
    await service.configure(
      androidConfiguration: AndroidConfiguration(
        onStart: onStart,
        autoStart: false,
        isForegroundMode: true,
        notificationChannelId: 'audio_record_channel',
        initialNotificationTitle: 'Audio Recording Service',
        initialNotificationContent: 'Recording in progress',
        foregroundServiceNotificationId: 888,
      ),
      iosConfiguration: IosConfiguration(
        autoStart: false,
        onForeground: onStart,
        onBackground: onIosBackground,
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Audio Recorder')),
      body: Center(
        child: ValueListenableBuilder<RecordingState>(
          valueListenable: audioRecorderService.recordingStateNotifier,
          builder: (context, recordingState, child) {
            return Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Icon(
                  recordingState == RecordingState.recording
                      ? Icons.mic
                      : (recordingState == RecordingState.paused
                      ? Icons.pause_circle
                      : Icons.mic_none),
                  size: 100,
                  color: recordingState == RecordingState.recording
                      ? Colors.red
                      : (recordingState == RecordingState.paused
                      ? Colors.orange
                      : Colors.blue),
                ),
                const SizedBox(height: 40),

                // Recording Controls
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    ElevatedButton.icon(
                      icon: Icon(
                        recordingState == RecordingState.recording
                            ? Icons.pause
                            : (recordingState == RecordingState.paused
                            ? Icons.play_arrow
                            : Icons.fiber_manual_record),
                      ),
                      label: Text(
                        recordingState == RecordingState.recording
                            ? 'Pause'
                            : (recordingState == RecordingState.paused
                            ? 'Resume'
                            : 'Record'),
                      ),
                      onPressed: () async {
                        if (recordingState == RecordingState.recording) {
                          await audioRecorderService.pauseRecording();
                        } else if (recordingState == RecordingState.paused) {
                          await audioRecorderService.resumeRecording();
                        } else {

                          await audioRecorderService.startRecording();
                        }
                      },
                      style: ElevatedButton.styleFrom(
                        backgroundColor: recordingState == RecordingState.recording
                            ? Colors.orange
                            : (recordingState == RecordingState.paused
                            ? Colors.green
                            : Colors.blue),
                        padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
                      ),
                    ),
                  ],
                ),
                const SizedBox(height: 40),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    ElevatedButton.icon(
                      icon: const Icon(Icons.check, color: Colors.white),
                      label: const Text('Save & Stop'),
                      onPressed: () async {
                        if (recordingState == RecordingState.recording) {
                          await audioRecorderService.stopRecording();
                          ScaffoldMessenger.of(context).showSnackBar(
                            const SnackBar(
                              content: Text("Audio recording saved!"),
                              duration: Duration(seconds: 2),
                            ),
                          );
                        }
                      },
                      style: ElevatedButton.styleFrom(
                        backgroundColor: Colors.green,
                        padding: const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
                      ),
                    ),
                  ],
                ),
                const SizedBox(height: 40),
                ElevatedButton(
                  onPressed: () {

                  },
                  child: const Text('Go to Player'),
                ),
              ],
            );
          },
        ),
      ),
    );
  }
}*/
